<?php

declare(strict_types=1);

namespace App\Controller\Cash\v1;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Service\UserService\CashManagerService;
use Hyperf\Di\Annotation\Inject;
use App\Middleware\CashMiddleware;
use Hyperf\HttpServer\Annotation\Middleware;
use Service\StoreService\StoreService;

/**
 * 登录控制器
 * @Controller(prefix="/cash/v1/login")
 * @Middleware(CashMiddleware::class)
 */
class LoginController extends AbstractController
{
    /**
     * @Inject
     * @var CashManagerService
     */
    protected $authService;
    
    /**
     * @Inject
     * @var StoreService
     */
    protected $storeService;
    
    /**
     * 登录接口
     * @RequestMapping(path="index", methods="post")
     */
    public function index(RequestInterface $request)
    {
        return $this->authService->userLogin($request->getParsedBody());
    }
    
    /**
     * 登录前根据mac获取该渠道下的所有店铺
     * @RequestMapping(path="storelist", methods="post")
     */
    public function storeList(RequestInterface $request)
    {
        return $this->storeService->getStoreByMac($request->getParsedBody());
    }
}